import { cloneDeep, } from 'lodash-es';

let dictDataList: DictDataRecord[] = [
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "性别男",
    "dictCode": 1,
    "dictSort": 1,
    "dictLabel": "男",
    "dictValue": "0",
    "dictType": "sys_user_sex",
    "cssClass": "",
    "listClass": "",
    "isDefault": "Y",
    "status": "0",
    "default": true
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "显示菜单",
    "dictCode": 4,
    "dictSort": 1,
    "dictLabel": "显示",
    "dictValue": "0",
    "dictType": "sys_show_hide",
    "cssClass": "",
    "listClass": "primary",
    "isDefault": "Y",
    "status": "0",
    "default": true
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "正常状态",
    "dictCode": 6,
    "dictSort": 1,
    "dictLabel": "正常",
    "dictValue": "0",
    "dictType": "sys_normal_disable",
    "cssClass": "",
    "listClass": "primary",
    "isDefault": "Y",
    "status": "0",
    "default": true
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "正常状态",
    "dictCode": 8,
    "dictSort": 1,
    "dictLabel": "正常",
    "dictValue": "0",
    "dictType": "sys_job_status",
    "cssClass": "",
    "listClass": "primary",
    "isDefault": "Y",
    "status": "0",
    "default": true
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "默认分组",
    "dictCode": 10,
    "dictSort": 1,
    "dictLabel": "默认",
    "dictValue": "DEFAULT",
    "dictType": "sys_job_group",
    "cssClass": "",
    "listClass": "",
    "isDefault": "Y",
    "status": "0",
    "default": true
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "系统默认是",
    "dictCode": 12,
    "dictSort": 1,
    "dictLabel": "是",
    "dictValue": "Y",
    "dictType": "sys_yes_no",
    "cssClass": "",
    "listClass": "primary",
    "isDefault": "Y",
    "status": "0",
    "default": true
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "通知",
    "dictCode": 14,
    "dictSort": 1,
    "dictLabel": "通知",
    "dictValue": "1",
    "dictType": "sys_notice_type",
    "cssClass": "",
    "listClass": "warning",
    "isDefault": "Y",
    "status": "0",
    "default": true
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "正常状态",
    "dictCode": 16,
    "dictSort": 1,
    "dictLabel": "正常",
    "dictValue": "0",
    "dictType": "sys_notice_status",
    "cssClass": "",
    "listClass": "primary",
    "isDefault": "Y",
    "status": "0",
    "default": true
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "新增操作",
    "dictCode": 19,
    "dictSort": 1,
    "dictLabel": "新增",
    "dictValue": "1",
    "dictType": "sys_oper_type",
    "cssClass": "",
    "listClass": "info",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "正常状态",
    "dictCode": 28,
    "dictSort": 1,
    "dictLabel": "成功",
    "dictValue": "0",
    "dictType": "sys_common_status",
    "cssClass": "",
    "listClass": "primary",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "性别女",
    "dictCode": 2,
    "dictSort": 2,
    "dictLabel": "女",
    "dictValue": "1",
    "dictType": "sys_user_sex",
    "cssClass": "",
    "listClass": "",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "隐藏菜单",
    "dictCode": 5,
    "dictSort": 2,
    "dictLabel": "隐藏",
    "dictValue": "1",
    "dictType": "sys_show_hide",
    "cssClass": "",
    "listClass": "danger",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "停用状态",
    "dictCode": 7,
    "dictSort": 2,
    "dictLabel": "停用",
    "dictValue": "1",
    "dictType": "sys_normal_disable",
    "cssClass": "",
    "listClass": "danger",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "停用状态",
    "dictCode": 9,
    "dictSort": 2,
    "dictLabel": "暂停",
    "dictValue": "1",
    "dictType": "sys_job_status",
    "cssClass": "",
    "listClass": "danger",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "系统分组",
    "dictCode": 11,
    "dictSort": 2,
    "dictLabel": "系统",
    "dictValue": "SYSTEM",
    "dictType": "sys_job_group",
    "cssClass": "",
    "listClass": "",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "系统默认否",
    "dictCode": 13,
    "dictSort": 2,
    "dictLabel": "否",
    "dictValue": "N",
    "dictType": "sys_yes_no",
    "cssClass": "",
    "listClass": "danger",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "公告",
    "dictCode": 15,
    "dictSort": 2,
    "dictLabel": "公告",
    "dictValue": "2",
    "dictType": "sys_notice_type",
    "cssClass": "",
    "listClass": "success",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "关闭状态",
    "dictCode": 17,
    "dictSort": 2,
    "dictLabel": "关闭",
    "dictValue": "1",
    "dictType": "sys_notice_status",
    "cssClass": "",
    "listClass": "danger",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "修改操作",
    "dictCode": 20,
    "dictSort": 2,
    "dictLabel": "修改",
    "dictValue": "2",
    "dictType": "sys_oper_type",
    "cssClass": "",
    "listClass": "info",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "停用状态",
    "dictCode": 29,
    "dictSort": 2,
    "dictLabel": "失败",
    "dictValue": "1",
    "dictType": "sys_common_status",
    "cssClass": "",
    "listClass": "danger",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "性别未知",
    "dictCode": 3,
    "dictSort": 3,
    "dictLabel": "未知",
    "dictValue": "2",
    "dictType": "sys_user_sex",
    "cssClass": "",
    "listClass": "",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "删除操作",
    "dictCode": 21,
    "dictSort": 3,
    "dictLabel": "删除",
    "dictValue": "3",
    "dictType": "sys_oper_type",
    "cssClass": "",
    "listClass": "danger",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "授权操作",
    "dictCode": 22,
    "dictSort": 4,
    "dictLabel": "授权",
    "dictValue": "4",
    "dictType": "sys_oper_type",
    "cssClass": "",
    "listClass": "primary",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "导出操作",
    "dictCode": 23,
    "dictSort": 5,
    "dictLabel": "导出",
    "dictValue": "5",
    "dictType": "sys_oper_type",
    "cssClass": "",
    "listClass": "warning",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "导入操作",
    "dictCode": 24,
    "dictSort": 6,
    "dictLabel": "导入",
    "dictValue": "6",
    "dictType": "sys_oper_type",
    "cssClass": "",
    "listClass": "warning",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "强退操作",
    "dictCode": 25,
    "dictSort": 7,
    "dictLabel": "强退",
    "dictValue": "7",
    "dictType": "sys_oper_type",
    "cssClass": "",
    "listClass": "danger",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "生成操作",
    "dictCode": 26,
    "dictSort": 8,
    "dictLabel": "生成代码",
    "dictValue": "8",
    "dictType": "sys_oper_type",
    "cssClass": "",
    "listClass": "warning",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "清空操作",
    "dictCode": 27,
    "dictSort": 9,
    "dictLabel": "清空数据",
    "dictValue": "9",
    "dictType": "sys_oper_type",
    "cssClass": "",
    "listClass": "danger",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "createBy": "admin",
    "createTime": "2024-07-07 17:41:52",
    "updateBy": null,
    "updateTime": null,
    "remark": "其他操作",
    "dictCode": 18,
    "dictSort": 99,
    "dictLabel": "其他",
    "dictValue": "0",
    "dictType": "sys_oper_type",
    "cssClass": "",
    "listClass": "info",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "searchValue": null,
    "createBy": "admin",
    "createTime": "2023-09-03 22:32:31",
    "updateBy": null,
    "updateTime": null,
    "remark": "打篮球",
    "params": {},
    "dictCode": 1,
    "dictSort": 1,
    "dictLabel": "打篮球",
    "dictValue": "0",
    "dictType": "sys_user_interest",
    "cssClass": "",
    "elTagType": "",
    "isDefault": "Y",
    "status": "0",
    "default": true
  },
  {
    "searchValue": null,
    "createBy": "admin",
    "createTime": "2023-09-03 22:32:31",
    "updateBy": null,
    "updateTime": null,
    "remark": "爬山",
    "params": {},
    "dictCode": 2,
    "dictSort": 2,
    "dictLabel": "爬山",
    "dictValue": "1",
    "dictType": "sys_user_interest",
    "cssClass": "",
    "elTagType": "",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "searchValue": null,
    "createBy": "admin",
    "createTime": "2023-09-03 22:32:31",
    "updateBy": null,
    "updateTime": null,
    "remark": "跑步",
    "params": {},
    "dictCode": 3,
    "dictSort": 3,
    "dictLabel": "跑步",
    "dictValue": "2",
    "dictType": "sys_user_interest",
    "cssClass": "",
    "elTagType": "",
    "isDefault": "N",
    "status": "0",
    "default": false
  },
  {
    "searchValue": null,
    "createBy": "admin",
    "createTime": "2023-09-03 22:32:31",
    "updateBy": null,
    "updateTime": null,
    "remark": "撩妹",
    "params": {},
    "dictCode": 4,
    "dictSort": 4,
    "dictLabel": "撩妹",
    "dictValue": "3",
    "dictType": "sys_user_interest",
    "cssClass": "",
    "elTagType": "",
    "isDefault": "N",
    "status": "0",
    "default": false
  }
];

const mocks: MockRecord[] = [
  {
    method: "get",
    url: "/api/system/dict/data/list",
    response(option) {
      let filterList = cloneDeep(dictDataList);

      if(option.query.dictType) {
        filterList = dictDataList.filter(item => item.dictType == option.query.dictType);
      }
      let copyList = cloneDeep(filterList);

      let resList = copyList;

      if (option.query.pageNum) {
        resList = filterList.splice((option.query.pageNum - 1) * option.query.pageSize, option.query.pageSize);
      }

      const resData: responseType = {
        code: 200,
        msg: "查询成功",
        total: copyList.length,
        ...(option.query.pageNum ? { rows: resList } : { data: resList })
      }

      return resData;
    }
  },
  {
    method: "get",
    url: "/api/system/dict/data/:dictCode",
    response(option) {
      const resDictData = dictDataList.find(item => item.dictCode == option.query.dictCode);

      const resData: responseType = {
        code: resDictData ? 200 : 500,
        msg: resDictData ? "查询成功" : "查询失败",
        data: resDictData,
      }

      return resData;
    }
  },
  {
    method: "post",
    url: "/api/system/dict/data",
    response(option) {
      const newDictData = option.body;

      newDictData.dictCode = dictDataList.length + 1;
      dictDataList.unshift(newDictData);

      const resData: responseType = {
        code: 200,
        msg: "新增成功",
      }

      return resData;
    }
  },
  {
    method: "put",
    url: "/api/system/dict/data",
    response(option) {
      const newDictData = option.body;

      const index = dictDataList.findIndex(item => item.dictCode == newDictData.dictCode);

      dictDataList.splice(index, 1, newDictData);

      const resData: responseType = {
        code: 200,
        msg: "修改成功",
      }

      return resData;
    }
  },
  {
    method: "delete",
    url: "/api/system/dict/data/:dictCodes",
    response(option) {
      const dictCodes = option.query.dictCodes.split(',');

      const filterList = dictDataList.filter(item => !dictCodes.includes(String(item.dictCode)));

      dictDataList = filterList;

      const resData: responseType = {
        code: 200,
        msg: "删除成功",
      }
      return resData;
    }
  }
];

export default mocks;